package com.oocl.euc.core.maintenance.repository;

import com.oocl.euc.core.maintenance.model.Users;
import com.oocl.euc.framework.base.persistence.IBaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UsersRepository extends IBaseRepository<Users, String> {

    @Query("SELECT u FROM Users u WHERE u.needSync = false")
    List<Users> getTempUsers();

    @Query("SELECT u FROM Users u WHERE u.domainId = ?1 AND u.active = true")
    Users findByDomainId(String domainId);

    @Query(value = "SELECT U.EMAIL FROM PCRS_USERS U WHERE U.USERSID IN ?1", nativeQuery = true)
    List<String> findUsersEmailByDomainId(List<String> domainIds);

    @Query(value="SELECT DISTINCT u.department FROM Users u WHERE u.needSync = false AND u.department IS NOT NULL")
    List<String> getUserDepartments();
}
